package com.wkq.util.transformer

import android.view.View
import androidx.viewpager2.widget.ViewPager2

/**
 *
 *@Author: wkq
 *
 *@Time: 2025/7/28 17:57
 *
 *@Desc: 卡片堆叠滑动（Depth）
 */
class DepthPageTransformer : ViewPager2.PageTransformer {
    override fun transformPage(view: View, position: Float) {
        when {
            position <= 0f -> {
                view.alpha = 1f
                view.translationX = 0f
                view.scaleX = 1f
                view.scaleY = 1f
            }
            position <= 1f -> {
                view.alpha = 1 - position
                view.translationX = view.width * -position
                val scale = 0.75f + (1 - 0.75f) * (1 - position)
                view.scaleX = scale
                view.scaleY = scale
            }
            else -> view.alpha = 0f
        }
    }
}
